import 'package:flutter/material.dart';
import 'package:hi_flutter/app_page.dart';

class TabViewDemoPage extends StatelessWidget {
  const TabViewDemoPage({super.key});

  @override
  Widget build(BuildContext context) {
    List<String> tabTitleList = ["新闻", "历史", "图片"];

    List<Widget> tabList = tabTitleList.map((e) => Tab(text: e)).toList();

    List<Widget> contentList = tabTitleList.map((e) {
      return Container(
        alignment: Alignment.center,
        child: Text(e, textScaler: const TextScaler.linear(5)),
      );
    }).toList();

    return AppPage(
      body: DefaultTabController(
          length: tabTitleList.length,
          child: Column(
            mainAxisSize: MainAxisSize.max,
            children: [
              TabBar(tabs: tabList),
              Expanded(
                child: TabBarView(
                  children: contentList,
                ),
              ),
            ],
          )),
    );
  }
}
